<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="uct" uri="/WEB-INF/uct.tld" %>
<%@ taglib prefix="portal" uri="/WEB-INF/portal.tld" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <%@ include file="/common/sale/include/common-base.jsp"%>
  <title>商品发行管理-${titleName}</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
</head>

<!-- 以下是body主体内容的模块区域 -->
<body class="hold-transition ${sysColor} sidebar-mini">
<div class="wrapper">

  <!-- top start -->
  <%@include file="/common/sale/top.jsp" %>
  <!-- top end -->
  <!-- left start -->
  <%@include file="/common/sale/left.jsp" %>
  <!-- left end-->

  <div class="content-wrapper">
    <!-- Main start -->
	<section class="content">
      <div class="row">
        <div class="col-xs-12">
        
          <!------搜索  start ------->
          <div class="box box-info">
             <!--搜索title  start --> 
	          <div class="box-header with-border">
                 <h3 class="box-title"><i class="fa fa-search"></i> 商品发行搜索</h3>
                 <div class="box-tools pull-right" style="display: none;">
	                <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
	                </button>
	                <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
                 </div>
              </div>
            <!--搜索title  end --> 
            <div class="box-body">
			  <form id="searchForm" class="form-horizontal">
				<input type="hidden" name="pageName" value="bjtesale-pub-list.jsp"/>
				<input type="hidden" name="formName" value="searchForm1">
				<input type="hidden" name="trsSale.w_delStatus" value="F">
				<input type="hidden" name="trsSale.w_proId" value="${param.proId}"/>
				<input type="hidden" name="trsSale.w_proNo" value="${param.proNo}"/>
				<input type="hidden" name="orderBy" value="trsSale.create_time desc">
				
				<div class="col-sm-11">
				   <div class="form-group">
						<div class="col-sm-2 text_r"><label class="control-label" >发行活动：</label></div>
						<div class="col-sm-2" >
							 <input type="text" class="form-control clean"  name="trsSale.wl_saleName" value="" id="search_saleName"/>
						</div>
						<div class="col-sm-2 text_r"><label class="control-label" >发行价格：</label></div>
						<div class="col-sm-2" >
							 <input type="text" class="form-control clean"  name="trsSale.wl_priceInit" value="" id="search_priceInit"/>
						</div>
						<div class="col-sm-2 text_r"><label class="control-label" >状态：</label></div>
						<div class="col-sm-2" >
							<!-- <input type="text" class="form-control clean"  name="trsSale.wl_saleStatus" value="" id="search_saleStatus"/> 
							<select id="searchForm_saleStatus" name="trsSale.saleStatus" class="form-control clean" 
		               		data-url="doCode=dymicSql&modelTypes=s_trpConstant&trpConstant.w_constantType='saleStatus'" data-colmun="{value:'saleStatus',text:'saleStatus'}" data-type="select" >
		               		</select>-->
							
							<select id="searchForm_saleStatus" name="trsSale.saleStatus" class="form-control clean" >
		               			<option id="" value="">--请选择--</option>
		               			<option id="" value="0" >暂存</option>
		               			<option id="" value="10" >审核中</option>
		               			<option id="" value="20" >审核通过</option>
		               			<option id="" value="21" >审核失败</option>
		               			<option id="" value="30" >正在发行</option>
		               			<option id="" value="40" >发行成功</option>
		               			<option id="" value="41" >发行失败</option>
		               			<option id="" value="50" >配号结束</option>
		               			<option id="" value="60" >摇号结束</option>
		               			<option id="" value="70" >扣款结束</option>
		               		</select>
						 </div>
					</div>
											
					<center>
					   <div class="box-footer clearfix">
					       <button type="button" class="btn btn-success" onclick="getTableData();"><i class="fa fa-edit-circle"></i> 查询</button> 
					       <button type="button" class="btn btn-warning" onclick="cleanData('searchForm');">重置 </button>
					   </div>
					</center>
				 </div>
			  </form>
            </div>
	     </div>
	     <!------- 搜索 end -------->
           
        <!------- 列表 start -------->
          <div class="box box-success">
            <!--列表title  start --> 
	          <div class="box-header with-border">
                 <h3 class="box-title"><i class="fa fa-user"></i> [${param.proNo}-${param.proName}] 发行列表 
                 　　　              <button  onclick="toAdd();" class="btn btn-success" type="button"><i class="fa fa-plus-circle"></i> 添加发行活动 </button>
                 </h3>
                 <div class="box-tools pull-right" style="display: none;">
	                 　　　　　　　　<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
	                </button>
	                <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
                 </div>
              </div>
            <!--列表title  end --> 
              <div class="box-body">
                <table id="dataList" class="table table-bordered table-hover" >
                <thead class="bg-success">
                <tr>
                        <th class="text_c">序号</th>
                        <th class="text_c">活动名称</th>
                        <th class="text_c">发行价格（元）</th>
                        <th class="text_c">发行总量</th>
                        <th class="text_c">开始日期</th>
                        <th class="text_c">结束日期</th>
                        <th class="text_c">状态</th>
                        <th class="text_c">创建时间</th>
                  		<th class="text_c">操作</th>
                </tr>
                </thead>
                <tbody id="dataList-body">
                </tbody>
              </table>
              <center>
    	  		<ul id="dataList-page"></ul>
              </center>
            </div>
           </div>
        <!------- 列表 end -------->
        </div>
      </div>
    </section>
    <!-- Main end -->
  </div>
  <!-- /.content-wrapper -->
  <!-- foot start -->
  <%@include file="/common/sale/foot.jsp" %>
  <!-- foot start -->
  

<div class="modal fade" id="my_modal_add" tabindex="-1" data-backdrop="static" data-keyboard="false" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog" style="width:800px;">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true" >
							×
						</button>
						<h4 class="modal-title">
							<font color="red">添加发行活动</font> 
						</h4>
					</div>

					<div class="modal-body">
						
					       <div class="nav-tabs-custom">
					            <ul class="nav nav-tabs" id="addmyTab">
					            </ul>
					            
					            <!-- tab content start -->
					            <div class="tab-content">
					                  
					               <div class="tab-pane active" id="addtab_1">
					                  <form class="form-horizontal" role="form" id="addForm1" action="javascript:void(0)">
					                    <input type="hidden" name="pageName" value="bjtesale-pub-list.jsp"/>
										<input type="hidden" name="formName" value="addForm1"/>
									    <input type="hidden" id="addForm1_formToken" name="formToken" />
										<input type="hidden" name="doCode" value="dymicSql"/>
										
										<input type="hidden" name="trpProduct.proStatus" value="10"/>
										<input type="hidden" name="trpProduct.w_proId" value="${param.proId}"/>
										<input type="hidden" name="trpProduct.w_proStatus" value="0"/>
										
							            
										<input type="hidden" name="trsSale.delStatus" value="F"/>
										<input type="hidden" name="trsSale.proId" value="${param.proId}"/>
										<input type="hidden" name="trsSale.proNo" value="${param.proNo}"/>
										<input type="hidden" name="trsSale.saleStatus" value="0"/>
										<div class="row">
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-5 control-label">活动名称：</label>
												<div class="col-sm-7">
													<input type="text" id="addForm1_saleName" data-name="trsSale.saleName" name="trsSale.saleName" class="form-control clean" maxLength="100"  placeholder="必填项" />
												</div>
											</div>
											
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-5 control-label">商品名称：</label>
												<div class="col-sm-7">
										  			<input class="form-control" data-name="trsSale.proName" readonly="readonly" id="addForm1_proName" name="trsSale.proName"  maxLength="100"  value="${param.proName}" />
												</div>
											</div>
										</div>
										<div class="row">
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-5 control-label">发行价格：</label>
												<div class="col-sm-7">
													<input type="text" id="addForm1_priceInit" data-name="trsSale.priceInit" name="trsSale.priceInit" maxlength="10" class="form-control clean"  placeholder="单位：元" />
												</div>
											</div>
											
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-5 control-label">发行总量：</label>
												<div class="col-sm-7">
													<input type="text" id="addForm1_saleNum" data-name="trsSale.saleNum" name="trsSale.saleNum" maxlength="8" class="form-control clean"  placeholder="必填项" />
												</div>
											</div>
										</div>
										<div class="row">
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-5 control-label">开始日期：</label>
												<div class="col-sm-7">
										  			<div class="input-append date form_datetime">
										    		<input style="width:88%" id="form1_saleDateStart" data-name="trsSale.saleDateStart" name="trsSale.saleDateStart" type="text" class="form-control datepicker" value="" readonly/>
										    		<span class="add-on"><i class="fa fa-calendar"></i></span>
										 			</div>
												</div>
											</div>
											
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-5 control-label">结束日期：</label>
												<div class="col-sm-7">
										  			<div class="input-append date form_datetime">
										    		<input style="width:88%" id="form1_saleDateEnd" data-name="trsSale.saleDateEnd" name="trsSale.saleDateEnd" type="text" class="form-control datepicker" value="" readonly/>
										    		<span class="add-on"><i class="fa fa-calendar"></i></span>
										 			</div>
												</div>
											</div>
										</div>
										<div class="row">
											<div class="form-group col-sm-6">
												<label  class="col-sm-5 control-label">发行申购类型：</label>
												<div class="col-sm-7">
													<select id="addForm1_trsSale_saleType" data-name="trsSale.saleType" name="trsSale.saleType" 
														class="form-control clean" data-url="doCode=dictItemList&amp;cateEname=saleType" data-colmun=""  data-type="select">
													</select>
												</div>
											</div>
											
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-5 control-label">发行成功比例：</label>
												<div class="col-sm-7">
													<input type="text" style="width:88%;" id="addForm1_saleRatio" data-name="trsSale.saleRatio" name="trsSale.saleRatio" maxlength="3" class="form-control clean"  placeholder="一般为80%" />%
												</div>
											</div>
										</div>
											
								        	<!--trsSale end-->
					                    
					                    <div class="form-group">
								        	<div class="col-sm-12">
									         <div class="box-footer text-center">
									         	<button class="btn btn-danger" type="button" style="width: 200px;" onclick="saveAddForm('addForm1','add');"> 保存 </button>
					            			</div>
				            				</div>
				            			</div>
					                  </form>
					               </div>
					               
				            </div>
					            <!-- tab content e -->
				          </div>	
			                
					</div>
				</div>
				<!-- /.modal-content -->
			</div>		
</div>  

<div class="modal fade" id="my_modal_edit" tabindex="-1" data-backdrop="static" data-keyboard="false" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog" style="width:800px;">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true" >
							×
						</button>
						<h4 class="modal-title">
							<font color="red">发行活动修改</font> 
						</h4>
					</div>
					<div class="modal-body">
						<div class="nav-tabs-custom">
					            <ul class="nav nav-tabs" id="myTab">
					            </ul>
					            
					            <!-- tab content start -->
					            <div class="tab-content">
					            
					                  
					               <div class="tab-pane active" id="edit_tab_1">
					                  <form class="form-horizontal" role="form" id="editForm1" action="javascript:void(0)">
					                    <input type="hidden" name="pageName" value="bjtesale-pub-list.jsp"/>
										<input type="hidden" name="formName" value="editForm1"/>
									    <input type="hidden" id="editForm1_formToken" name="formToken" />
										<input type="hidden" name="doCode" value="dymicSql"/>
										<input type="hidden" name="trsSale.w_saleId" class="clean" data-name="trsSale.saleId"/>
										<input type="hidden" name="trsSale.proId" class="clean" data-name="trsSale.proId"/>
										
										
							                <!--trsSale start-->
										<div class="row">
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-5 control-label">活动名称：</label>
												<div class="col-sm-7">
														<input type="text" id="editForm1_saleName" data-name="trsSale.saleName" name="trsSale.saleName" class="form-control clean"  placeholder="必填项" />
												</div>
											</div>
											
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-5 control-label">商品名称：</label>
												<div class="col-sm-7">
										  			<input class="form-control clean" data-name="trsSale.proName" readonly="readonly" id="editForm1_proName" name="trsSale.proName"  maxLength="200" />
												</div>
											</div>
										</div>
										<div class="row">
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-5 control-label">发行价格：</label>
												<div class="col-sm-7">
														<input type="text" id="editForm1_priceInit" data-name="trsSale.priceInit" name="trsSale.priceInit" maxlength="10" class="form-control clean"  placeholder="单位：元" />
												</div>
											</div>
											
											
											
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-5 control-label">发行总量：</label>
												<div class="col-sm-7">
														<input type="text" id="editForm1_saleNum" data-name="trsSale.saleNum" name="trsSale.saleNum" maxlength="5" class="form-control clean"  placeholder="必填项" />
												</div>
											</div>
										</div>
										<div class="row">
						                	<!-- <div class="form-group col-sm-6">
												<label  class="col-sm-5 control-label">发行模式</label>
												<div class="col-sm-7">
														<input type="text" id="editForm1_saleModel" data-name="trsSale.saleModel" name="trsSale.saleModel" class="form-control clean"  placeholder="必填项" />
												</div>
											</div>
											
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-5 control-label">发行方式</label>
												<div class="col-sm-7">
														<input type="text" id="editForm1_saleType" data-name="trsSale.saleType" name="trsSale.saleType" class="form-control clean"  placeholder="必填项" />
												</div>
											</div> -->
											
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-5 control-label">开始日期：</label>
												<div class="col-sm-7">
										  			<div class="input-append date form_datetime">
										    		<input style="width:88%" id="editForm1_saleDateStart" data-name="trsSale.saleDateStart" name="trsSale.saleDateStart" type="text" class="form-control datepicker" value="" readonly/>
										    		<span class="add-on"><i class="fa fa-calendar"></i></span>
										 			</div>
												</div>
											</div>
											
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-5 control-label">结束日期：</label>
												<div class="col-sm-7">
										  			<div class="input-append date form_datetime">
										    		<input style="width:88%" id="editForm1_saleDateEnd" data-name="trsSale.saleDateEnd" name="trsSale.saleDateEnd" type="text" class="form-control datepicker" value="" readonly/>
										    		<span class="add-on"><i class="fa fa-calendar"></i></span>
										 			</div>
												</div>
											</div>
										</div>
										<div class="row">
											<div class="form-group col-sm-6">
												<label  class="col-sm-5 control-label">发行申购类型：</label>
												<div class="col-sm-7">
													<select id="editForm1_trsSale_saleType" data-name="trsSale.saleType" name="trsSale.saleType" 
														class="form-control clean" data-url="doCode=dictItemList&amp;cateEname=saleType" data-colmun=""  data-type="select">
													</select>
												</div>
											</div>
											
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-5 control-label">发行成功比例：</label>
												<div class="col-sm-7">
														<input type="text" style="width: 100px;" id="editForm1_saleRatio" data-name="trsSale.saleRatio" name="trsSale.saleRatio" maxlength="3" class="form-control clean"  placeholder="必填项" />%
												</div>
											</div>
										</div>
										<!-- 
										<div class="row">
						                	<div class="form-group col-sm-12">
													<div class="col-sm-3" align="right"  style="margin-left: -35px;">
														<i class="fa fa-info-circle red" style="color:#FFCC33;"></i>审核建议：
													</div>
													<div class="col-sm-9" align="left">
														<span style="color: red" data-name="trsSale.auditSuggest" ></span>
													</div>
											</div>
										</div>
										 -->	
						                	<!-- <div class="form-group col-sm-6">
												<label  class="col-sm-5 control-label">最大申购量</label>
												<div class="col-sm-7">
														<input type="text" id="editForm1_numMax" data-name="trsSale.numMax" name="trsSale.numMax" class="form-control clean"  placeholder="必填项" />
												</div>
											</div>
											
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-5 control-label">最小申购量</label>
												<div class="col-sm-7">
														<input type="text" id="editForm1_numMin" data-name="trsSale.numMin" name="trsSale.numMin" class="form-control clean"  placeholder="必填项" />
												</div>
											</div> -->
											
								        	<!--trsSale end-->
					                    
					                    <div class="form-group">
								        	<div class="col-sm-12">
									         <div class="box-footer text-center">
									         	<button class="btn btn-danger" type="button" style="width: 200px;" onclick="submitForm1('editForm1');"> 保存 </button>
					            			</div>
				            				</div>
				            			</div>
					                  </form>
					               </div>
					          
				            </div>
					            <!-- tab content e -->
				          </div>	
					</div>
				</div>
				<!-- /.modal-content -->
			</div>		
</div>  
<!--lichengfei20170103  -->

<div win-title="查看窗口" class="modal fade" id="my_modal_view" tabindex="-2" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog" style="width:800px;">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							×
						</button>
						<h4 class="modal-title">
							<font color="red">发行活动详情</font> 
						</h4>
					</div>
					<div class="modal-body">
						<div class="nav-tabs-custom">
					            <ul class="nav nav-tabs" id="viewmyTab">
						          <li class="active" id="tab1"><a href="#tab_1" data-toggle="tab">活动信息</a></li>
					              <li id="tab2"><a href="#tab_2" data-toggle="tab">发行规则</a></li>
					            </ul>
					            
					            <!-- tab content start -->
					            <div class="tab-content">
					            
					                  
					               <div class="tab-pane active" id="tab_1">
					                  <form class="form-horizontal" role="form" id="viewForm1" action="javascript:void(0)">
							                <!--trsSale start-->
											
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-6 control-label">活动名称：</label>
												<div class="col-sm-6 control-label1 form-control-static">
													<span data-name="trsSale.saleName"></span>
												</div>
											</div>
											
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-6 control-label">商品名称：</label>
												<div class="col-sm-6 control-label1 form-control-static">
													<span data-name="trsSale.proName"></span>
												</div>
											</div>
											
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-6 control-label">发行价格：</label>
												<div class="col-sm-6 control-label1 form-control-static">
													<span data-name="trsSale.priceInit"></span> 元
												</div>
											</div>
											
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-6 control-label">发行总量：</label>
												<div class="col-sm-6 control-label1 form-control-static">
													<span class="control-label" data-name="trsSale.saleNum"></span>
												</div>
											</div>
											
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-6 control-label">开始日期：</label>
												<div class="col-sm-6 control-label1 form-control-static">
													<span data-name="trsSale.saleDateStart"></span>
												</div>
											</div>
											
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-6 control-label">结束日期：</label>
												<div class="col-sm-6 control-label1 form-control-static">
													<span data-name="trsSale.saleDateEnd"></span>
												</div>
											</div>
											
											<div class="form-group col-sm-6">
												<label  class="col-sm-6 control-label">发行申购类型：</label>
												<div class="col-sm-6 control-label1 form-control-static">
													<span data-name="trsSale.saleType" data-dict-url="doCode=dictItemList&amp;cateEname=saleType"></span>
												</div>
											</div>
											
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-6 control-label">发行成功比例：</label>
												<div class="col-sm-6 control-label1 form-control-static">
													<span data-name="trsSale.saleRatio" style="width: 100px;" ></span> %
												</div>
											</div>
											
											<!-- 
											<div class="form-group col-sm-12" >
												<label  class="col-sm-3 control-label" style="margin-left: -8px;"><i class="fa fa-info-circle red" style="color:#FFCC33;"></i>审核建议：</label>
													<span class="col-sm-9 control-label1" style="color: red" data-name="trsSale.auditSuggest"></span>
											</div>
											 -->
								        	<!--trsSale end-->
					                    
					                    <div class="form-group">
								        	<div class="col-sm-12">
									         <div class="box-footer text-center">
									         	<button class="btn btn-danger" type="button" style="width: 200px;" onclick="cannel('view');"> 关闭 </button>
					            			</div>
				            				</div>
				            			</div>
					                  </form>
					               </div>
					               
					               
					               <div class="tab-pane" id="tab_2">
					                  <form class="form-horizontal" role="form" id="RulesViewForm1" action="javascript:void(0)">
							                <!--trsRulesPro start-->
						                	<div id="view-rulesproview-body" class="col-sm-12">
											</div>
								        	<!--trsRulesPro end-->
					                    <div class="form-group">
								        	<div class="col-sm-12">
									         <div class="box-footer text-center">
									         	<button class="btn btn-danger" type="button" style="width: 200px;" onclick="cannel('view');"> 关闭 </button>
					            			</div>
				            				</div>
				            			</div>
					                  </form>
					               </div>
					          
					          
					          
				            </div>
					            <!-- tab content e -->
				          </div>	
					</div>
				</div>
				<!-- /.modal-content -->
			</div>		
</div>


<div win-title="审核窗口" class="modal fade" id="my_modal_audit" tabindex="-2" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog" style="width:800px;">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							×
						</button>
						<h4 class="modal-title">
							<font color="red">发行活动审核</font> 
						</h4>
					</div>
					<div class="modal-body">
						<div class="nav-tabs-custom">
					            <ul class="nav nav-tabs" id="auditmyTab">
					              <li class="active" id="audit_tab"><a href="#audit_tab_1" data-toggle="tab">活动信息</a></li>
					              <li id="audit_tab2"><a href="#audit_tab_2" data-toggle="tab">发行规则</a></li>
					            </ul>
					            
					            <!-- tab content start -->
					            <div class="tab-content">
					               <div class="tab-pane active" id="audit_tab_1">
							                <!--trsSale start-->
							            
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-5 control-label">活动名称：</label>
												<div class="col-sm-7 control-label">
													<span data-name="trsSale.saleName"></span>
												</div>
											</div>
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-5 control-label">商品名称：</label>
												<div class="col-sm-7 control-label">
													<span data-name="trsSale.proName"></span>
												</div>
											</div>
									
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-5 control-label">发行价格：</label>
												<div class="col-sm-7 control-label">
													<span data-name="trsSale.priceInit"></span> 元
												</div>
											</div>
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-5 control-label">发行总量：</label>
												<div class="col-sm-7 control-label">
													<span data-name="trsSale.saleNum"></span>
												</div>
											</div>
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-5 control-label">开始日期：</label>
												<div class="col-sm-7 control-label">
													<span data-name="trsSale.saleDateStart"></span>
												</div>
											</div>
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-5 control-label">结束日期：</label>
												<div class="col-sm-7 control-label">
													<span data-name="trsSale.saleDateEnd"></span>
												</div>
											</div>
											<div class="form-group col-sm-6">
												<label  class="col-sm-5 control-label">发行申购类型：</label>
												<div class="col-sm-7 control-label">
													<span data-name="trsSale.saleType" data-dict-url="doCode=dictItemList&amp;cateEname=saleType"></span>
												</div>
											</div>
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-5 control-label">发行成功比例：</label>
												<div class="col-sm-7 control-label">
													<span data-name="trsSale.saleRatio"></span> %
												</div>
											</div>
											
								        	<!--trsSale end-->
					                 
					               </div>
					          
					          
					          		<div class="tab-pane" id="audit_tab_2">
							                <!--trsRulesPro start-->
						                	<div id="audit-rulesproview-body" class="col-sm-12">
											</div>
								        	<!--trsRulesPro end-->
					               </div>
					               
					          <form class="form-horizontal" role="form" id="auditForm1" action="javascript:void(0)">
					               		<input type="hidden" name="pageName" value="bjtesale-pub-list.jsp"/>
										<input type="hidden" name="formName" value="editForm1"/>
									    <input type="hidden" id="auditForm1_formToken" name="formToken" />
										<input type="hidden" name="doCode" value="dymicSql"/>
										<input type="hidden" name="trsSale.w_saleId" class="clean" data-name="trsSale.saleId"/>
										<input type="hidden" id="auditForm1_saleStatus" name="trsSale.saleStatus" class="clean" value="20"/>
					                 
					                 <div class="form-group col-sm-12" >
												<label  class="col-sm-3 control-label" style="margin-left: -6px;">审核建议：</label>
												<div class="col-sm-9">
										  			<textarea class="form-control clean" style="width: 400px;" rows="4" id="editForm1_auditSuggest" name="trsSale.auditSuggest"  maxLength="500" placeholder="最多输入500字"></textarea>
												</div>
									</div>
					                 <div class="form-group">
								        	<div class="col-sm-12">
									         <div class="box-footer text-center">
									         	<button class="btn btn-danger" type="button" style="width: 100px;" onclick="audit('auditForm1','F');">审核不通过</button>
									         	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									         	<button class="btn btn-success" type="button" style="width: 100px;" onclick="audit('auditForm1','T');">审核通过</button>
					            			</div>
				            				</div>
				            		</div>
					           </form>
				            </div>
					            <!-- tab content e -->
				          </div>	
					</div>
				</div>
				<!-- /.modal-content -->
			</div>		
</div>

<div class="modal fade" id="my_modal_rules" tabindex="-1" data-backdrop="static" data-keyboard="false" role="dialog"  aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog" style="width:800px;">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							×
						</button>
						<h4 class="modal-title">
							<font color="red">设置发行规则</font> 
						</h4>
					</div>

					<div class="modal-body">
						<form id="trpRulesProAllDivForm" style="display:none;">
							<input  name="pageName" value="trs-rules-pro"/>
							<input  name="formName" value="addFormInitData"/>
							<input  name="ifBatch" value="T"/>
							<input  name="trsRulesPro.splitAttr" value="rulesNo"/>
							<div id="trpRulesProAllDiv"></div>
						</form>
					       <div class="nav-tabs-custom">
					            
					            <!-- tab content start -->
					            <div class="tab-content">
					            
					               <div class="tab-pane active" id="rulestab_1">
					                  <form class="form-horizontal" role="form" id="rulesForm1" action="javascript:void(0)">
							             	
							             	<input type="hidden" name="pageName" value="bjtesale-pub-list.jsp"/>
											<input type="hidden" name="formName" value="editForm1"/>
											<input type="hidden" name="formToken"/>
										    <input type="hidden" id="rules_w_sale_id" class="rules_w_sale_id" name="trsSale.w_saleId" />
											<input type="hidden" name="trsSale.saleStatus" value="10"/>
											<div class="form-group col-sm-12">
												<label class="col-sm-2 control-label">商品代码：</label>
												<div class=" col-sm-2"><input type="text" class="form-control" value="${param.proNo}" name="trsSale.proNom"  readonly="readonly"/></div>
												<label class="col-sm-2 control-label">商品名称:</label>
												<div class=" col-sm-2"><input type="text" class="form-control" value="${param.proName}" readonly="readonly"/></div>
												<label class="col-sm-2 control-label">发行总量:</label>
												<div class=" col-sm-2"><input type="text" class="form-control" name="trsSale.saleNum"  readonly="readonly"/></div>
											</div>
											<div class="form-group col-sm-12" style="margin-left: 20px;">
							                		<i class="fa fa-info-circle red" style="color:#FFCC33;"></i> 提示：
							                		您正在设置此商品的 <label id="rulesProWin-saleName" class="control-label"></label> 活动的发行规则
							                		<a href="javascript:void(0);" style="color:red;" onclick="resetRulsPro('rules_w_sale_id')">【点此】</a>可以初始化系统规则进行重新设置。
											</div>
											
						                	<div id="rulespro-body" class="col-sm-12">
											</div>
						                	
								        	<!--trsRulePro end-->
								        
					                    <div class="form-group">
								        	<div class="col-sm-12">
									         <div class="box-footer text-center">
									         	<button class="btn btn-danger" type="button" style="width: 200px;" onclick="submitFormRules('rulesForm1','rules');"> 设置完成 </button>
					            			</div>
				            				</div>
				            			</div>
				            			
					                  </form>
					               </div>
					          
				            </div>
					            <!-- tab content e -->
				          </div>	
			                
					</div>
				</div>
				<!-- /.modal-content -->
			</div>		
</div>  

<div win-title="发行费用规则窗口" class="modal fade" id="my_modal_fee" tabindex="-2" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog" style="width:800px;">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							×
						</button>
						<h4 class="modal-title">
							<font color="red">发行费用规则设置</font> 
						</h4>
					</div>
					<div class="modal-body">
						<div class="nav-tabs-custom">
					            
					            <!-- tab content start -->
					            <div class="tab-content">
					               <div class="tab-pane active" id="audit_tab_1">
							                <!--trsSale start-->
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-6 control-label">发行活动：</label>
												<div class="col-sm-6 control-label1">
													<span data-name="trsSale.saleName"></span>
												</div>
											</div>
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-6 control-label">产品名称：</label>
												<div class="col-sm-6 control-label1">
													<span data-name="trsSale.proName"></span>
												</div>
											</div>
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-6 control-label">发行价格：</label>
												<div class="col-sm-6 control-label1">
													<span data-name="trsSale.priceInit"></span> 元
												</div>
											</div>
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-6 control-label">发行总量：</label>
												<div class="col-sm-6 control-label1">
													<span data-name="trsSale.saleNum"></span>
												</div>
											</div>
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-6 control-label">开始日期：</label>
												<div class="col-sm-6 control-label1">
													<span data-name="trsSale.saleDateStart"></span>
												</div>
											</div>
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-6 control-label">结束日期：</label>
												<div class="col-sm-6 control-label1">
													<span data-name="trsSale.saleDateEnd"></span>
												</div>
											</div>
											<div class="form-group col-sm-12">
												<label  class="col-sm-4 control-label">交易商手续费比例：</label>
												<div class="col-sm-7 control-label1">
													<input type="text"  name=""  class="form-control clean"  placeholder="必填项" />
												</div>
											</div>
						                	<div class="form-group col-sm-12">
												<label  class="col-sm-4 control-label">交易商市场留存比例：</label>
												<div class="col-sm-7 control-label1">
													<input type="text"  name=""  class="form-control clean"  placeholder="必填项" />
												</div>
											</div>
											<div class="form-group col-sm-12">
												<label  class="col-sm-4 control-label">发行商手续费比例：</label>
												<div class="col-sm-7 control-label1">
													<input type="text"  name=""  class="form-control clean"  placeholder="必填项" />
												</div>
											</div>
											<div class="form-group col-sm-12">
												<label  class="col-sm-4 control-label">发行商市场留存比例：</label>
												<div class="col-sm-7 control-label1">
													<input type="text"  name=""  class="form-control clean"  placeholder="必填项" />
												</div>
											</div>
								        	<!--trsSale end-->
					                 
					               </div>
					          
					          
					          		<div class="tab-pane" id="audit_tab_2">
							                <!--trsRulesPro start-->
						                	<div id="audit-rulesproview-body" class="col-sm-12">
											</div>
								        	<!--trsRulesPro end-->
					               </div>
					               
					          <form class="form-horizontal" role="form" id="auditForm1" action="javascript:void(0)">
					               		<input type="hidden" name="pageName" value="bjtesale-pub-list.jsp"/>
										<input type="hidden" name="formName" value="editForm1"/>
									    <!-- <input type="hidden" id="auditForm1_formToken" name="formToken" />  -->
										<input type="hidden" name="doCode" value="dymicSql"/>
										<input type="hidden" name="trsSale.w_saleId" class="clean" data-name="trsSale.saleId"/>
										<input type="hidden" id="auditForm1_saleStatus" name="trsSale.saleStatus" class="clean" value="20"/>
					                 
					                 <div class="form-group">
								        	<div class="col-sm-12">
									         <div class="box-footer text-center">
									         	<button class="btn btn-danger" type="button" style="width: 100px;" onclick="audit('auditForm1','F');">保存设置</button>
									         	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					            			</div>
				            				</div>
				            		</div>
					           </form>
				            </div>
					            <!-- tab content e -->
				          </div>	
					</div>
				</div>
				<!-- /.modal-content -->
			</div>		
</div>


<!-- 发行 -->
<div class="modal fade" id="my_modal_sale" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog" style="width:200px;">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							×
						</button>
						<h4 class="modal-title">
							<font color="red">发行</font> 
						</h4>
					</div>

					<div class="modal-body">
						
					       <div class="nav-tabs-custom">
					            <ul class="nav nav-tabs" id="rulesmyTab">
					            </ul>
					            
					            <!-- tab content start -->
					            <div class="tab-content">
					            
					               
					               <div class="tab-pane active" id="rulestab_3">
					                  <form class="form-horizontal" role="form" id="rulesForm3" action="javascript:void(0)">

										  	<input type="hidden" name="pageName" value="bjtesale-pub-list.jsp"/>
										  	<input type="hidden" name="formName" value="editForm1"/>
										    <input type="hidden" class="rules_w_sale_id" name="trsSale.w_saleId" />
											<input type="hidden" name="trsSale.saleStatus" value="30"/>
										
						                <!-- 	<div class="form-group col-sm-12">
												<label  class="col-sm-4 control-label">${param.proName}(${param.proNo})</label>
												<label id="rulesProWin-saleName" class="col-sm-4 control-label"></label>
											</div>
										 
						                	<div id="rulespro-body" class="col-sm-12">
											</div>
						                -->	
								        	<!--trsRulePro end-->
								        
					                    <div class="form-group">
								        	<div class="col-sm-12">
									         <div class="box-footer text-center">
									         	<button class="btn btn-danger" type="button" style="width: 200px;" onclick="submitForm('rulesForm3','rules');">确定发行</button>
					            			</div>
				            				</div>
				            			</div>
				            			
					                  </form>
					               </div>
					          
				            </div>
					            <!-- tab content e -->
				          </div>	
			                
					</div>
				</div>
				<!-- /.modal-content -->
			</div>		
</div>  


</body>

<!-- 以下是template列表模板的模块区域 -->
<script type="text/template" id="dataList-template">
		<? for ( var i = 0; i < rows.length; i++) {?>
		<tr>
			<td class="text_c"><?=(pageObj.currentPage-1)*10+(i+1)?></td>
			<td class="text_l"><?=strUtil.subStr(rows[i].saleName,'7')?></td>
			<td class="text_r">￥<?=fmoney(rows[i].priceInit,'')?></td>
			<td class="text_r"><?=strUtil.doNull(rows[i].saleNum,'')?></td>
			<td class="text_c"><?=strUtil.doNull(rows[i].saleDateStart,'')?></td>
			<td class="text_c"><?=strUtil.doNull(rows[i].saleDateEnd,'')?></td>
            <td class="text_c" status="<?=rows[i].saleStatus?>">
				<? if('0' == rows[i].saleStatus){ ?>暂存
				<? } else if ('10' == rows[i].saleStatus){?>审核中
				<? } else if ('20' == rows[i].saleStatus){?>审核通过
				<? } else if ('21' == rows[i].saleStatus){?>审核失败
				<? } else if ('30' == rows[i].saleStatus){?>正在发行
				<? } else if ('40' == rows[i].saleStatus){?>发行成功
				<? } else if ('41' == rows[i].saleStatus){?>发行失败
				<? } else if ('50' == rows[i].saleStatus){?>配号结束
				<? } else if ('60' == rows[i].saleStatus){?>摇号结束
				<? } else if ('70' == rows[i].saleStatus){?>扣款结束
				<? }?>
			</td>
			<td class="text_c"><?=strUtil.doNull(rows[i].createTime,'')?></td><!--数据库中修改时间和修改人存入的值反了，这里每个状态的变更时间都是每个动作的时间起始点 -->
				<td>
					<button type="button" class="btn btn-success btn-xs" onclick="toLoad1('<?=rows[i].saleId?>','view')">查看</button>  
					<? if('0' == rows[i].saleStatus){ ?>
						<button type="button" class="btn btn-warning btn-xs" onclick="toLoad1('<?=rows[i].saleId?>','edit');">修改</button>  
						<button type="button" class="btn btn-danger btn-xs" onclick="toDele('<?=rows[i].saleId?>');">删除</button>  
						<button type="button" class="btn btn-warning btn-xs" onclick="openRulesPro('<?=rows[i].saleId?>','<?=rows[i].saleName?>','<?=rows[i].saleNum?>');">设置发行规则</button>
					<? }?>
					<? if('10' == rows[i].saleStatus){ ?>
						<button type="button" class="btn btn-warning btn-xs" onclick="toLoad1('<?=rows[i].saleId?>','edit');">修改</button>  
						<button type="button" class="btn btn-primary btn-xs" onclick="toLoad1('<?=rows[i].saleId?>','audit')">审核</button>  
						<button type="button" class="btn btn-warning btn-xs" onclick="openRulesPro('<?=rows[i].saleId?>','<?=rows[i].saleName?>','<?=rows[i].saleNum?>');">设置发行规则</button>
					<? }?>
					<? if('20' == rows[i].saleStatus){?>
						<button type="button" class="btn btn-info btn-xs" onclick="toSale('<?=rows[i].saleId?>','30')">手动发行</button>
						  
					<? }?>
					<? if('21' == rows[i].saleStatus){?>
						<button type="button" class="btn btn-warning btn-xs" onclick="toLoad1('<?=rows[i].saleId?>','edit');">修改</button>  
						<button type="button" class="btn btn-primary btn-xs" onclick="toLoad1('<?=rows[i].saleId?>','audit')">再次审核</button>  
						<button type="button" class="btn btn-info btn-xs" onclick="openRulesPro('<?=rows[i].saleId?>','<?=rows[i].saleName?>','<?=rows[i].saleNum?>');">重置发行规则</button>
					<? }?>
					<? if('30' == rows[i].saleStatus){?>
						<button type="button" class="btn btn-warning btn-xs" onclick="toFinishSale('<?=rows[i].saleId?>','40','<?=rows[i].saleDateEnd?>')">结束发行</button>  
					<? }?>
					<? if('40' == rows[i].saleStatus){?>
						<button type="button" class="btn btn-warning btn-xs" onclick="toPeiHao('<?=rows[i].saleId?>')">开始配号</button>  
					<? }?>
					
					<? if('41' == rows[i].saleStatus){?>
						<button type="button" class="btn btn-danger btn-xs" onclick="toBuy('<?=rows[i].saleId?>','<?=rows[i].cateId?>','<?=rows[i].proId?>','<?=rows[i].proNo?>','<?=rows[i].proName?>','<?=rows[i].saleName?>');">申购记录</button>  
					<? }?>
					
					<? if('50' == rows[i].saleStatus){?>
						<button type="button" class="btn btn-warning btn-xs" onclick="toYaoHao('<?=rows[i].saleId?>')">执行摇号</button>  
					<? }?>

					<? if('60' == rows[i].saleStatus){?>
						<button type="button" class="btn btn-danger btn-xs" onclick="toKouKuan('<?=rows[i].saleId?>','view')">中签扣款</button>  
					<? }?>
					<? if(rows[i].saleStatus*1==30 && rows[i].saleStatus !=41){?>
						<button type="button" class="btn btn-danger btn-xs" onclick="toBuy('<?=rows[i].saleId?>','<?=rows[i].cateId?>','<?=rows[i].proId?>','<?=rows[i].proNo?>','<?=rows[i].proName?>','<?=rows[i].saleName?>');">申购记录</button>  
					<? }?>
					<? if(rows[i].saleStatus*1>=50){?>
						<button type="button" class="btn btn-danger btn-xs" onclick="toBuy('<?=rows[i].saleId?>','<?=rows[i].cateId?>','<?=rows[i].proId?>','<?=rows[i].proNo?>','<?=rows[i].proName?>','<?=rows[i].saleName?>');">申购记录</button>  
						<button type="button" class="btn btn-warning btn-xs" onclick="toViewPeiHao('<?=rows[i].saleId?>')">配号结果</button>  
					<? }?>
				</td>
		</tr>
   <?}?>  		
</script>
<script type="text/template" id="rulespro-template">
		<? for ( var i = 0; i < rows.length; i++) {?>
		<div class="form-group col-sm-10">
			<label  class="col-sm-5 control-label"><?=(i+1)?>.<?=rows[i].trsRulesPro.formulaName?></label>
			<div class="col-sm-6">
				<input id="rsp-<?=rows[i].trsRulesPro.rulesProId?>" name="<?=rows[i].trsRulesPro.rulesNo?>" data-bv-regexp="<?=strUtil.doNull(rows[i].trsRulesPro.showValid,'')?>"
					   data-bv-regexp-message="<?=strUtil.doNull(rows[i].trsRulesPro.showTip,'必填项')?>" onblur="saveRulesPro(this)"
					   formulaSrc="<?=rows[i].trsRulesPro.formulaSrc?>" paramNo="<?=rows[i].trsRulesPro.paramNo?>"
					   paramName="<?=rows[i].trsRulesPro.paramName?>" rulesproid="<?=rows[i].trsRulesPro.rulesProId?>"
					   class="form-control saleRules fx12" value="<?=strUtil.doNull(rows[i].trsRulesPro.paramNo,'')?>" maxlength="12"/>
				<span style="color:#dd4b39;font-size:12px;">*格式是<?=strUtil.doNull(rows[i].trsRulesPro.showTip,'必填项')?></span>
			</div>
		</div>
   <?}?>  		
</script>

<script type="text/template" id="rulesproview-template">
		<? for ( var i = 0; i < rows.length; i++) {?>
				<div class="form-group col-sm-6">
					<label  class="col-sm-6 control-label"><?=(i+1)?>.<?=rows[i].trsRulesPro.formulaName?></label>
					<div class="col-sm-6 control-label1 form-control-static">
							<span ><?=strUtil.doNull(rows[i].trsRulesPro.paramNo,'')?></span>
					</div>
				</div>

   <?}?>  		
</script>
</html>

<!-- 以下是js模块区域 -->
<script>
var clickMenu = "bjtesale-sale-list";
//var chickMenu = "bjtesale-pub-list";
var id,myPage,dataListId,searchFormId,isShowLog,tableSort,tableId,token;
myPage = 10;
dataListId = "dataList";
searchFormId = "searchForm";
tableSort = "trsSale";
tableId = "saleId";
isShowLog = true;

$(function () {
	//1、加载分页列表数据
	//DictUtil.getCommonDictData("select","#searchForm_saleStatus","trsSale.w_saleStatus","doCode=dymicSql&modelTypes=s_trpConstant&trpConstant.w_trpConstant=saleStatus&trpConstant.w_delStatus=F","{value:'saleStatus',text:'saleStatus'}","");
	getTableData();
	//2、控制是否启用token
	setToken();
	
	//请在下面补充其他初始化方法（如数据字典、页面加载数据等）
	//3、初始化数据字典  data-url="doCode=dictItemList&cateEname=saleStatus"
	//DictUtil.getCommonDictData("select","#searchForm_saleStatus","trsSale.saleStatus","doCode=dymicSql&modelTypes=s_trpConstant&trpConstant.w_constantType=saleStatus&trpConstant.w_delStatus=F","{value:'saleStatus',text:'saleStatus'}","");
	DictUtil.getCommonDictData("select","#addForm1_trsSale_saleType","trsSale.saleType","doCode=dictItemList&cateEname=saleType","","");
 });
 
 //日期控件校验
var form1_saleDateStart = $('#form1_saleDateStart').datepicker( {
	language : 'zh-CN',
	//inline: true,
	todayBtn : "linked",//显示今天
	format : "yyyy-mm-dd",
	autoclose: true,//自动关闭
	todayHighlight : true,  //高亮
	startDate : new Date()  //由今天开始
}).on('changeDate',function(e){  
    var startTime = e.date;  
    $('#form1_saleDateEnd').datepicker('setStartDate',startTime);  
});

var form1_saleDateEnd = $('#form1_saleDateEnd').datepicker( {
	language : 'zh-CN',
	todayBtn : "linked",
	format : "yyyy-mm-dd",
	autoclose: true,
});

var editForm1_saleDateStart = $('#editForm1_saleDateStart').datepicker( {
	language : 'zh-CN',
	//inline: true,
	todayBtn : "linked",
	format : "yyyy-mm-dd",
	autoclose: true,
	todayHighlight : true,  
	startDate : new Date() 
}).on('changeDate',function(e){  
    var startTime = e.date;  
    $('#editForm1_saleDateEnd').datepicker('setStartDate',startTime);  
});

var editForm1_saleDateEnd = $('#editForm1_saleDateEnd').datepicker( {
	language : 'zh-CN',
	todayBtn : "linked",
	format : "yyyy-mm-dd",
	autoclose: true,
});

//toLoad1 读取（查询、编辑）数据
function toLoad1(id,type){
	showModal(type);
	//发售基本信息
	loadSaleBaseInfo(id);
	//发售规则
	loadSaleRules(id,type);
}

function loadSaleBaseInfo(id){
	var paramLoadData = {"formName":"searchForm1","pageName":"bjtesale-pub-list.jsp","trsSale.w_saleId":id};
	$.ajax({
	    type:'get',
	   	url:common_info_url+"?doCode=dymicSql",
	    data: paramLoadData,
	    async:false,
	    dataType:"json",
	    success: function(myData){
	    	//console.log(myData);
			FormUtil.loadView("trsSale", myData);
			$("input[name='trsSale.w_saleId']").val(id);//之前审核方法不好使，id值未赋上
<%--			DictUtil.getCommonDictData("select","#editForm1_trsSale_saleType","trsSale.saleType","doCode=dictItemList&cateEname=saleType","",myData.trsSale.saleType);--%>
			
	  	}
	});
	
}


function loadSaleRules(saleId,type){
	  var paramData = {"pageName":"trs-rules-pro","formName":"searchForm","trsRulesPro.w_showFlag":"T","trsRulesPro.w_saleId":saleId,"orderBy":"trsRulesPro.rules_no"};
	  $.ajax({
		   type:'get',
		   url:common_list_url,
		   data:paramData,
		   dataType:'json',
		   success: function(myData){
				console.log(myData);
			   if(myData.flag="T"){
				   var data = baidu.template("rulesproview-template",eval(myData));  
					$("#"+type+"-rulesproview-body").html(data);
			   }
		   }
	  }); 
}

function toDele(id){
	var index_submit = layer.confirm('您确定要删除信息吗？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
	, function(){
		layer.close(index_submit);
		
		//删除规则子表
		delSaleRules(id);
		//删除主表
		doDele(id);
	});
}
//弹框
function showModal(type){
	if("view"==type){
		$("#my_modal_view").modal("show");
	}else if("edit"==type){
		//修改弹框时，初始化数据字典
		cleanData('editForm1');
		setValidate("editForm1");//2.校验规则-弹框窗口加载定义方法
		DictUtil.getCommonDictData("select","#editForm1_trsSale_saleType","trsSale.saleType","doCode=dictItemList&cateEname=saleType","","");
		$("#my_modal_edit").modal("show");
	}else if("audit"==type){
		//修改弹框时，初始化数据字典
		cleanData('editForm1');
		$("#editForm1_auditSuggest").nextAll("span").remove();//清除校验记录
		$("#editForm1_auditSuggest").val("");
		$("#my_modal_audit").modal("show");
	}
}

$(function () {
	$('#'+dataListId+' tbody').on('click','tr', function (e) {
	     if ( $(this).hasClass('selected') ) {
	            //$(this).removeClass('selected');
	        }
	        else {
	            $('tr.selected').removeClass('selected');
	            $(this).addClass('selected');
	        }
	     id = $('tr.selected td').eq(0).html();
	   //  console.log($('tr.selected td').eq(1).html())
	} );
	
  });
//加载列表数据
function getTableData(){
	deleteAllRow(dataListId);

	//搜索去除空格
	$("#search_saleName").val($("#search_saleName").val().trim());
	$("#search_priceInit").val($("#search_priceInit").val().trim());
	$.ajax({
		   type:'get',
		   url:common_list_url,
		   data:$("#"+searchFormId).serialize()+getCurrentPage(common_list_url+"?"+$("#"+searchFormId).serialize(),myPage),
		   dataType:'json',
		   success: function(myData){
		   if(isShowLog)console.log(myData);
			var data = baidu.template(dataListId+"-template",eval(myData));  
			$("#"+dataListId+"-body").html(data);
			  var option= {
					   ele:$("#"+dataListId+"-page")[0],
					   total:myData.total,
					   fn:getTableData,
					   url:common_list_url+"?"+$("#"+searchFormId).serialize()
				   }
				generatePages(option);
		   }
		});	
  }

//回车查询
document.onkeydown=function mykeyDown(e){  
      //compatible IE and firefox because there is not event in firefox  
       e = e||event;  
       if(e.keyCode == 13) {getTableData();}   
       return;  
};


//设置模态框隐藏事件 
$( '#my_modal_add' ).on( 'show.bs.modal' ,function(e){  
	setToken();
	cleanJiaoyan("addForm1");
}); 
//修改窗口，点击空白处校验未清空，设置修改窗口再次打开时清空校验
$( '#my_modal_edit' ).on( 'show.bs.modal' ,function(e){  
	setToken();
	cleanJiaoyan("editForm1");
}); 
//清空数据
function cleanData(id){
	$('#'+id).find(".clean").val("");//按照样式清空；
}
//打开添加页面
function toAdd(){
	if(chechSaleCount()){
		layer.alert("已存在正在发行的活动，暂时不能添加");
		return;
	}
	cleanData('addForm1');//清空模态窗口内数据
	setValidate("addForm1");//2.校验规则-弹框窗口加载定义方法
	$("#w_"+tableId).val("");
	$(".datepicker").val("");
	$('#my_modal_add').modal('show');
}
//判断该商品放行状态的个数
function chechSaleCount(){
	var flag = false;
	var proId = $("#addForm1").find("input[name='trsSale.proId']").val();
	var paramData = {"formName":"searchForm1","pageName":"bjtesale-pub-list.jsp","trsSale.w_saleStatus":"30","trsSale.w_proId":proId};
	$.ajax({
		   type:'get',
		   url:common_list_url,
		   data:paramData,
		   dataType:'json',
		   async:false,
		   success: function(myData){
			console.log(myData);
			//循环遍历规则列表
			if(myData.total>0){
				flag = true;
			}
		   }
		});	
	return flag;
}

//获取对象值
function loadObj(type,paramData){
	$.ajax({
	    type:'get',
	   	url:common_info_url+"?doCode=dymicSql",
	    data: paramData,
	    async:false,
	    dataType:"json",
	    success: function(myData){
	    	showData(type,myData);
	  	}
	});	
}

//删除信息（逻辑删除）
function doDele(id){
	setToken();
	var doDeleParamData = {"formName":"delForm","pageName":"trs-sale","trsSale.w_saleId":id,"formToken":token};
	$.ajax({
	    type:"post",
	    url:common_submit_url+"?doCode=dymicSql",
	    data: doDeleParamData,
	    dataType:"json",
	    success: function(myData){
	    	var result = myData.flag;
	    	if(result=="T"){
	    		layer.alert("删除操作成功",{yes:function(){
		    		refresh();
	    		}});
	    	}
	  	}
	});	
}

//1.表单提交前：校验规则-定义
function setValidate(formId){
	$('#'+formId).bootstrapValidator({
	 //  excluded: [':disabled'],
	   feedbackIcons: {
	        valid: 'glyphicon glyphicon-ok',
	        invalid: 'glyphicon glyphicon-remove',
	        validating: 'glyphicon glyphicon-refresh'
	    },
	    fields: {
	        "trsSale.saleName": {
	            validators: {
	                notEmpty: {
	                    message: '活动名称不能为空！'	
	                }
	            }
	        },
	        "trsSale.priceInit":{
	        	validators: {
			        notEmpty: {
		                message: '发行价格不能为空！'
		            },
		            numeric: {
		                message: '价格只能为数字！且不能大于99999'
		            },
		            greaterThan:{
                        value: 0.1,
	                    message: '价格不能小于0.1'
	                }
	            }
	        },
	        "trsSale.saleNum":{
	        	validators: {
	                notEmpty: {
	                    message: '发行总量不能为空！'
	                },
	                numeric: {
		                message: '只能填写数字！'
		            },
		            greaterThan:{
                        value: 1,
	                    message: '发行总量不能小于1！'
	                }
	            }
	        }, 
	        "trsSale.saleDateStart": {
	            validators: {
	                notEmpty: {
	                    message: '开始日期不能为空！'	
	                }
	            }
	        },
	        "trsSale.saleDateEnd": {
	            validators: {
	                notEmpty: {
	                    message: '结束日期不能为空！'	
	                }
	            }
	        },
	        "trsSale.saleType": {
	            validators: {
	                notEmpty: {
	                    message: '请选择发行申购类型！'	
	                }
	            }
	        },
	        "trsSale.saleRatio": {
	            validators: {
	                notEmpty: {
	                    message: '发行成功比例不能为空！'	
	                },
	                numeric: {
		                message: '请填写0~100之间的数字！'
		            },
		            greaterThan:{
                        value: 0,
	                    message: '请输入最小为0的数字！'
	                },
	                lessThan:{
	                	value: 101,
	                    message: '发行比例不能超过100！'
	                }
	            }
	        },
	    }
	});
}
//提交规则验证
function submitFormRules(formId,type){
	var flag = true;
	var saleNum=$("#"+formId).find("input[name='trsSale.saleNum']").val();//发行总量
	var sale01Obj = $("#"+formId).find("input[name='sale01']");//最小申购变动单位
	var sale02Obj = $("#"+formId).find("input[name='sale02']");//申购上限
	var sale03Obj = $("#"+formId).find("input[name='sale03']");//申购下限
	if(strUtil.isNull(sale01Obj.val())||strUtil.isNull(sale02Obj.val())||strUtil.isNull(sale03Obj.val())){
		layer.alert("还有发行规则未设置");
		return;
	}
	if(sale01Obj.val()*1<100){
		layer.tips("最小变动量不能少于100", '#'+sale01Obj.attr("id"), {tips: 2});
		sale01Obj.val("");
		return;
	}
	if(sale01Obj.val()*1>saleNum*1){
		layer.tips("最小变动量不能大于发行总量["+saleNum+"]", '#'+sale01Obj.attr("id"), {tips: 2});
		sale01Obj.val("");
		return;
	}
	if((saleNum*1)%(sale01Obj.val()*1)!=0){
		layer.tips("最小变动量必须能被发行总量["+saleNum+"]整除", '#'+sale01Obj.attr("id"), {tips: 2});
		sale01Obj.val("");
		return;
	}
	if(sale02Obj.val()*1>saleNum*1){
		layer.tips("申购上限不能大于发行总量["+saleNum+"]", '#'+sale02Obj.attr("id"), {tips: 2});
		sale02Obj.val("");
		return;
	}
	if((sale02Obj.val()*1)%(sale01Obj.val()*1)!=0){
		layer.tips("申购上限必须是["+sale01Obj.val()+"]的整数倍", '#'+sale02Obj.attr("id"), {tips: 2});
		sale02Obj.val("");
		return;
	}
	if(sale03Obj.val()*1<sale01Obj.val()*1){
		layer.tips("申购下限不能小于最小变动量["+sale01Obj.val()+"]", '#'+sale03Obj.attr("id"), {tips: 2});
		sale03Obj.val("");
		return;
	}
	if((sale03Obj.val()*1)%(sale01Obj.val()*1)!=0){
		layer.tips("申购下限必须是["+sale01Obj.val()+"]的整数倍", '#'+sale03Obj.attr("id"), {tips: 2});
		sale03Obj.val("");
		return;
	}
	if(flag){
		var index_submit = layer.confirm('您确认发行规则设置完成吗 ？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
		, function(){
			submitForm(formId,type);
		})
	}
}
//表单提交
function submitForm(formId,type){
	var result;
	var index_load = layer.load(1, {shade: false});
	setToken();
	$.ajax({
	    type:'post',
	    url:common_submit_url,
	    data:$("#"+formId).serialize(),
	    async:false,
	    dataType:'json',
	    success: function(myData){ 
	     console.log(myData);
	        if(myData.flag=="T"){
	        	result = myData;
	        	layer.alert("保存成功",{yes:function(){
		        	cannel(type);
		        	refresh();
	        	}});
	    	}else{
	     		layer.alert(myData.msg);
	    	}
	        layer.close(index_load);

	  	},
	     error: function (e) {
		     layer.close(index_load);
     	} 
	});	
	return result;
}



//关闭win
function cannel(type){
	if(strUtil.isNull(type)){
		$('#my_modal_add').modal('hide');
	}else{
		$('#my_modal_'+type).modal('hide');
	}
}

function refresh(){
	window.location.reload();
}


/****  以下是自定义新增方法  ****/

//清空校验规则
function cleanJiaoyan(formId){
		var validate = $('#'+formId).data('bootstrapValidator').validate();
		validate.resetForm();
}

//添加页面保存
function saveAddForm(formId,type){
	//3.校验规则-表单提交时触发
	var validate = $('#'+formId).data('bootstrapValidator').validate();
	if(!validate.isValid()){ //如果校验不通过
	    return;  
	} 
	
	var index_submit = layer.confirm('您确定要保存信息吗？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
	, function(){
		layer.close(index_submit);
		var index_load = layer.load(2, {shade: false,offset: '220px'});
		$.ajax({
		    type:'post',
		    url:common_submit_url,
		    data:$("#"+formId).serialize(),
		    async:false,
		    dataType:'json',
		    success: function(myData){ 
		     console.log(myData);
		        if(myData.flag=="T"){
		        	var saleId = myData.ids.trsSale_saleId;
		    		//addSaleRules(formId,saleId);
		        	layer.close(index_load);
		        	layer.alert(myData.msg,{yes:function(){
			        	cannel(type);
			        	refresh();
			        	validate.resetForm();//提交成功后，删除校验方法
		        	}})
		    	}
		  	}
		});
	});
}
//获取品种下商品申购时定义的规则，实例此商品规则。
function addSaleRules(formId,saleId){
    var msgIndex = layer.msg("正在初始化交易参数");
    var proId = $("#"+formId).find("input[name='trsSale.proId']").val();
    var paramData = {"pageName":"trs-rules-pro","formName":"addFormInitData","sysRulesProd.w_cateNo":"${param.cateNo}","trsRulesPro.prodId":proId,"trsRulesPro.saleId":saleId,"rulesType":"rengou","formToken":token};
    $.ajax({
        type:'post',
        url:common_submit_url,
        data:paramData,
        dataType:'json',
        async:false,
        success: function(myData){
            console.log("初始化结果：",myData);
            if("T"==myData.flag){
                // layer.alert("初始化成功！");
                layer.close(msgIndex);
            }else{
                msgIndex = layer.msg("初始化失败！"+myData.msg);
            }
        }
    });
}
/**
 function addSaleRules(formId,saleId){
	var proId = $("#"+formId).find("input[name='trsSale.proId']").val();
	var paramData = {"pageName":"sysRulesProd-list","formName":"searchForm","sysRulesProd.w_cateNo":"${param.cateNo}","sysRulesProd.w_rulesType":"rengou"};
	$.ajax({
		   type:'get',
		   url:common_list_url,
		   data:paramData,
		   dataType:'json',
		   async:false,
		   success: function(myData){
			console.log(myData);
			//循环遍历规则列表
			if(myData.total>1){
				var objHtmlAll="";
				for(var i=0;i<myData.rows.length;i++){
					var rulesObj = myData.rows[i].sysRulesProd;
					
					var newObj = {};
					for(var name in rulesObj){
						newObj["trsRulesPro."+name] = rulesObj[name];
					}
					newObj["trsRulesPro.saleId"] = saleId;
					newObj["trsRulesPro.prodId"] = proId;
                    newObj["trsRulesPro.createTime"] = new Date().format("yyyy-MM-dd hh:mm:ss");
					for(key in newObj){
						objHtmlAll+="<input name='"+key+"' value='"+strUtil.doNull(newObj[key],'')+"'/>";
					}
					objHtmlAll+="<br/><br/>";
					console.log("newObj["+i+"]",newObj);
				  	
				}
				$("#trpRulesProAllDiv").html(objHtmlAll);
				setToken();
				 $.ajax({
					   type:'post',dataType:'json',data:$("#trpRulesProAllDivForm").serialize(),async:false,
					   //url:common_submit_url+"?doCode=dymicSql&modelTypes=i_trsRulesPro",
					   url:common_submit_url+"?formToken="+token,
					   success: function(myData){console.log("初始化结果：",myData); }
				 });
			}
		   }
		});	
  }
 **/
/**
 *

 function addSaleRulesOld(formId,saleId){
	var proId = $("#"+formId).find("input[name='trsSale.proId']").val();
	//var paramData = {"doCode":"dymicSql","modelTypes":"s_trpRulesParam","trpRulesParam.w_cateNo":"${param.cateNo}","trpRulesParam.w_constantType":"apply_status","trpRulesParam.w_constantStatus":"10"};
	var paramData = {"doCode":"dymicSql","modelTypes":"s_trpRulesParam","trpRulesParam.w_cateNo":"${param.cateNo}","trpRulesParam.w_rulesType":"rengou"};
	$.ajax({
		   type:'get',
		   url:common_list_url,
		   data:paramData,
		   dataType:'json',
		   async:false,
		   success: function(myData){
			//console.log(myData);
			//循环遍历规则列表
			if(myData.total>1){
				var strTemp = "";
				var newObj = {};
				for(var i=0;i<myData.rows.length;i++){
					var rulesObj = myData.rows[i];
					var obj = {}
					//console.info(rulesObj);
					for(var name in rulesObj){
						strTemp = strTemp+",\"trsRulesPro."+name+"\":"+"\""+rulesObj[name]+"\"";
					}
					strTemp = strTemp+",\"trsRulesPro.saleId\":\""+saleId+"\"";
					strTemp = strTemp+",\"trsRulesPro.prodId\":\""+proId+"\"";
				}
				strTemp = strTemp.substring(1,strTemp.length);
				strTemp = "{"+strTemp+"}";
				//console.log(JSON.stringify(newObj));
				console.log(strTemp);
				console.log(JSON.parse(strTemp));
				setToken();
				var urlStr = common_submit_url+"?doCode=dymicSql&modelTypes=ib_trsRulesPro&ifBatch=T&trsRulesPro.splitAttr=rulesNo&formToken="+token;
				console.info(urlStr);
			}
		   }
		});	
  }
 */

  //删除规则设置
  function delSaleRules(id){
	  setToken();
	  var delSaleRulesParamData = {"pageName":"trs-rules-pro","formName":"delForm","trsRulesPro.w_saleId":id,"formToken":token};
	  $.ajax({
		   type:'post',
		   url:common_submit_url,
		   data:delSaleRulesParamData,
		   dataType:'json',
		   success: function(myData){
				console.log(myData);
			   if(myData.flag="T"){
				   //refresh();
			   }
		   }
	  });
  }
  
  //打开设置规则窗口
  function openRulesPro(saleId,saleName,saleNum){
	  var proRulesData = getProRules(saleId);
	  if(proRulesData.total==0){
		  var msgIndex = layer.msg("正在初始化发行规则");
		  addSaleRules("addForm1",saleId);
		  layer.close(msgIndex);
	  }
	  $("#rulesForm1").find("input[name='trsSale.saleNum']").val(saleNum);
	  $("#rulesProWin-saleName").text(saleName);
	  $(".rules_w_sale_id").val(saleId);
	  setToken()
	  var paramData = {"pageName":"trs-rules-pro","formName":"searchForm","trsRulesPro.w_showFlag":"T","trsRulesPro.w_saleId":saleId,"orderBy":"trsRulesPro.rules_no","formToken":token};
	  $.ajax({
		   type:'get',
		   url:common_list_url,
		   data:paramData,
		   dataType:'json',
		   success: function(myData){
				console.log(myData);
			   if(myData.flag="T"){
				   var data = baidu.template("rulespro-template",eval(myData));  
					$("#rulespro-body").html(data);
					$('#my_modal_rules').modal('show');
			   }
		   }
	  }); 

  }  
  
 
  //自动保存每个规则参数值
  function saveRulesPro(o){
	  var obj = $(o);
	  var objId = obj.attr("id");
	  var paramNoNew = obj.val();
	  
	  var pattern = obj.attr("data-bv-regexp");
	  var patternMess = obj.attr("data-bv-regexp-message");
	 /** if(strUtil.isNull(paramNoNew)){
		  layer.tips("不能为空", '#'+objId, {tips: 3});
		  $("#"+objId).focus();
		  return;
	  }
	  **/
	 if(!strUtil.isNull(pattern)){
         var regObj = new RegExp(pattern);
         // var regObj = new RegExp("^\\+?[1-9]\\d*$");
         //var regObj = new RegExp("(" + pattern + ")");
         var result = regObj.test(paramNoNew);
         //var result = paramNoNew.match(regObj);
         if(!result){
             layer.tips(patternMess, '#'+objId, {tips: 2});
             $("#"+objId).focus();
             obj.val("");
             return;
         }
	 }
	  var paramName = obj.attr("paramName");
	  var paramNoOld = obj.attr("paramNo");
	  var rpid = obj.attr("rulesproid");
	  
	  setToken();
	  if(paramNoNew && paramNoNew!==paramNoOld){
		  
		  var formulaSrc = obj.attr("formulaSrc");
		  var inputName = "trsRulesPro.paramNo";
		  var formulaCalNew = formulaSrc;
		  //alert(paramNoNew+"-"+formulaCalNew);
		  if(formulaSrc.indexOf(inputName)>-1){
			  //formulaCalNew=formulaSrc.replace(inputName,paramNoNew);
			  formulaCalNew = formulaSrc.replace(new RegExp(inputName,"gm"),paramNoNew);//进行多行全局匹配
		  }
		  var paramData = {"pageName":"trs-rules-pro","formName":"editForm","trsRulesPro.w_rulesProId":rpid,"trsRulesPro.paramName":paramName,"trsRulesPro.paramNo":paramNoNew,"trsRulesPro.formulaCal":formulaCalNew,"formToken":token};
		  $.ajax({
			   type:'post',
			   url:common_submit_url,
			   data:paramData,
			   dataType:'json',
			   success: function(myData){
					console.log(myData);
				   if(myData.flag="T"){
					   obj.attr("paramNo",paramNoNew);
					   layer.tips("保存成功", '#'+objId, {tips: 2,yes:function(){
						   refresh();
					   }});
				   }
			   }
		  });
	  }
  }
  
  
  //获取本活动的所有规则数据
  function getProRules(saleId){
	  var proRulesData = null;
	  var paramData = {"pageName":"trs-rules-pro","formName":"searchForm","trsRulesPro.w_rulesType":"rengou","trsRulesPro.w_saleId":saleId};
	  $.ajax({
		   type:'get',
		   url:common_list_url,
		   data:paramData,
		   dataType:'json',
		   async:false,
		   success: function(myData){
			   console.log(myData);
			   proRulesData = myData;
		   }
	  });
	  return proRulesData;
  }
  //删除此发售活动的之前设置规则，重新添加
  function resetRulsPro(sobjId){
	  var saleId = $("#"+sobjId).val();
	  var index_submit = layer.confirm('删除后需要重新设置各项规则，您确定删除吗？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
		, function(){
			layer.close(index_submit);
			delSaleRules(saleId);
			cannel("rules");//关闭窗口，下一次打开自动初始化；
		});
	 
  }

  //审核方法
  function audit(formId,flag){
	  if(flag=="T"){
		  $("#auditForm1_saleStatus").val("20");
	  var index_submit = layer.confirm('您确定要审核通过吗？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
		, function(){
			layer.close(index_submit);
			var index_load = layer.load(2, {shade: false,offset: '220px'});
			$.ajax({
			    type:'post',
			    url:common_submit_url,
			    data:$("#"+formId).serialize(),
			    async:false,
			    dataType:'json',
			    success: function(myData){ 
			     console.log(myData);
			        if(myData.flag=="T"){
			        	layer.close(index_load);
			        	cannel("audit");
			        	refresh();
			    	}
			  	}
			});
		});
	  }else{
		  $("#auditForm1_saleStatus").val("21");
		  if($("#editForm1_auditSuggest").val().trim() ==""){
			  $("#editForm1_auditSuggest").nextAll("span").remove();
			  $("#editForm1_auditSuggest").after("<span style='color:red;'><br/>请输入审核失败的原因，修改建议！</span>");
			  return;
		  }
		  
		  var index_submit = layer.confirm('您确定要审核失败吗？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
			, function(){
				layer.close(index_submit);
				var index_load = layer.load(2, {shade: false,offset: '220px'});
				$.ajax({
				    type:'post',
				    url:common_submit_url,
				    data:$("#"+formId).serialize(),
				    async:false,
				    dataType:'json',
				    success: function(myData){ 
				     console.log(myData);
				        if(myData.flag=="T"){
				        	layer.close(index_load);
				        	cannel("audit");
				        	refresh();
				    	}
				  	}
				});
			});
	  }
	}
  
  //修改保存方法
  function submitForm1(formId,type){
		//3.校验规则-表单提交时触发
		var validate = $('#'+formId).data('bootstrapValidator').validate();
		if(!validate.isValid()){ //如果校验不通过
		    return;  
		} 
	  
	  var index_submit = layer.confirm('您确定要保存信息吗？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
		, function(){
			layer.close(index_submit);
			var index_load = layer.load(2, {shade: false,offset: '220px'});
			$.ajax({
			    type:'post',
			    url:common_submit_url,
			    data:$("#"+formId).serialize(),
			    async:false,
			    dataType:'json',
			    success: function(myData){ 
			     console.log(myData);
			        if(myData.flag=="T"){
			        	layer.close(index_load);
			        	cannel("edit");
			        	refresh();
			        	validate.resetForm();//提交成功后，删除校验方法
			    	}
			  	}
			});
		});
  }
  //开始配号
  function toPeiHao(saleId){
	  setToken();
	  var index_submit = layer.confirm('您确定可以开始申购配号了吗？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
		, function(){
			layer.close(index_submit);
			var index_load = layer.load(2, {shade: false,offset: '220px'});
			var paramData = {"pageName":"bjtesale-pub-list.jsp",
					 "formName":"peihaoForm1","trsSale.w_saleId":saleId,
					 "trsSale.saleStatus":"50","formToken":token};
			$.ajax({
			    type:'post',
			    url:common_submit_url,
			    data:paramData,
			    async:false,
			    dataType:'json',
			    success: function(myData){ 
			     console.log(myData);
			        if(myData.flag=="T"){
			        	layer.close(index_load);
			        	refresh();
			    	}else{
                        layer.close(index_load);
                        layer.alert("操作失败："+myData.msg);
					}
			  	}
			});
		});
  }
  
  //开始摇号
  function toYaoHao(saleId){
	  setToken();
	  var index_submit = layer.confirm('您确定开始摇号吗？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
		, function(){
			layer.close(index_submit);
			var index_load = layer.load(2, {shade: false,offset: '220px'});
			var paramData = {"pageName":"bjtesale-pub-list.jsp",
					 "formName":"yaohaoForm1","trsSale.w_saleId":saleId,
					 "trsSale.saleStatus":"60","formToken":token};
			$.ajax({
			    type:'post',
			    url:common_submit_url,
			    data:paramData,
			    async:false,
			    dataType:'json',
			    success: function(myData){ 
			     console.log(myData);
			        if(myData.flag=="T"){
			        	layer.close(index_load);
			        	refresh();
			    	}
			  	}
			});
		});
  }
  
//开始扣款
  function toKouKuan(saleId){
	setToken();
	  var index_submit = layer.confirm('您确定要扣款吗？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
		, function(){
			layer.close(index_submit);
			var index_load = layer.msg("正在执行中签扣款，");
			var paramData = {"pageName":"bjtesale-pub-list.jsp",
					 "formName":"payForm1","trsSale.w_saleId":saleId,
					 "trsSale.saleStatus":"70","formToken":token};
			$.ajax({
			    type:'post',
			    url:common_submit_url,
			    data:paramData,
			    async:false,
			    dataType:'json',
			    success: function(myData){ 
			     console.log(myData);
		        	layer.close(index_load);
			        if(myData.flag=="T"){
			        	refresh();
			    	}
			  	}
			});
		});
  }
  
  function toSale(saleId,status){
	  if(chechSaleCount()){
			layer.alert("已存在正在发行的活动，暂时不能添加");
			return;
		}
	  setToken();
	  var index_submit = layer.confirm("是否确定发行？", {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
	  , function(){
			layer.close(index_submit);
			var index_load = layer.load(2, {shade: false,offset: '220px'});
			var paramData = {"doCode":"dymicSql","pageName":"bjtesale-pub-list.jsp",
					 "formName":"editForm1","trsSale.w_saleId":saleId,
					 "trsSale.saleStatus":status,"formToken":token};
			$.ajax({
			    type:'post',
			    url:common_submit_url,
			    data:paramData,
			    async:false,
			    dataType:'json',
			    success: function(myData){ 
			     console.log(myData);
			        if(myData.flag=="T"){
			        	layer.close(index_load);
			        	refresh();
			    	}
			  	}
			});
		});
  }
  
  function toFinishSale(saleId,status,saleDateEnd){
	  var nowTime = new Date().format("yyyy-MM-dd");
	  var message = "";
	  if(nowTime<saleDateEnd){
		  message="未达到活动发行结束时间，您确定要结束发行吗？";
	  }else{
		  message="您确定要结束发行吗？";
	  }
	 setToken();
		  var index_submit = layer.confirm(message, {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
			, function(){
				layer.close(index_submit);
				var index_load = layer.load(2, {shade: false,offset: '220px'});
				var paramData = {"doCode":"dymicSql","pageName":"bjtesale-pub-list.jsp",
						 "formName":"finishActivityForm1","trsSale.w_saleId":saleId,"formToken":token};
				$.ajax({
				    type:'post',
				    url:common_submit_url,
				    data:paramData,
				    async:false,
				    dataType:'json',
				    success: function(result){ 
				    	var isFinish = "";
				    	layer.close(index_load);
				    	var msg = eval("("+result.msg+")");
			    		var index_confirm = layer.confirm(msg.msg+"您确定要结束发行吗？", {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
						, function(){
							layer.close(index_confirm);
							if(msg.result=="T"){
								isFinish="N";
							}
							if(msg.result=="F"){
								isFinish="T";
							}
							setToken();
							var params = {"doCode":"dymicSql","pageName":"bjtesale-pub-list.jsp",
									 "formName":"finishActivityForm1","trsSale.w_saleId":saleId,"isFinish":isFinish,"formToken":token};
							$.ajax({
								type:'post',
								url:common_submit_url,
								data:params,
								dataType:'json',
								success:function(result){
									if(result.flag=="T"){
							        	refresh();
									}
								}
							});
						});
				  	}
				});
			})
  }
  
  function toViewPeiHao(saleId){

	  var url ="${page_admin}/sale/sale-yaohao-list?saleId="+saleId+"&proNo=${param.proNo}&proName=${param.proName}";	
	  window.location.href=encodeURI(url);

  }
  
//查看申购历史记录
  function toBuy(saleId,cateNo,proId,proNo,proName,saleName){

	  var url ="${page_admin}/sale/bjtesale-buy-list?saleId="+saleId+"&proId="+proId+"&proNo="+proNo+"&proName="+proName;	
	  window.location.href=encodeURI(url);

  }
</script>



